﻿using AutoMapper;
using QuanLyGiaoVuDAL.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuanLyGiaoVuUI.Models.MonHoc
{
    public class BoMonViewModel
    {
        public int? MaBoMon { get; set; }

        public String TenBoMon { get; set; }

        public IEnumerable<BoMonDTO> DanhSachBoMon { get; set; }

        public BoMonDTO ToBoMonDTO()
        {
            BoMonDTO boMonDTO = new BoMonDTO();
            Mapper.CreateMap(typeof(BoMonViewModel), typeof(BoMonDTO));
            Mapper.Map(this, boMonDTO);
            return boMonDTO;
        }

        public static BoMonViewModel FromBoMonDTO(BoMonDTO boMonDTO)
        {
            BoMonViewModel boMonViewModel = new BoMonViewModel();
            Mapper.CreateMap(typeof(BoMonDTO), typeof(BoMonViewModel));
            Mapper.Map(boMonDTO, boMonViewModel);
            return boMonViewModel;
        }

        public static IEnumerable<BoMonViewModel> FromBoMonDTOList(IEnumerable<BoMonDTO> boMonDTOList)
        {
            List<BoMonViewModel> boMonViewModelList = new List<BoMonViewModel>();
            foreach (BoMonDTO boMonDTO in boMonDTOList)
            {
                boMonViewModelList.Add(BoMonViewModel.FromBoMonDTO(boMonDTO));
            }
            return boMonViewModelList;
        }
    }
}